package com.liangzi.service_core.controller;


import com.liangzi.liangzi_common.result.R;
import com.liangzi.service_core.pojo.vo.InnerDoctorWorkVO;
import com.liangzi.service_core.service.InnerDoctorService;
import com.liangzi.service_core.service.InnerDoctorWorkService;
import com.liangzi.servicebase.util.RedisUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;

/**
 * <p>
 * 医生排班表 前端控制器
 * </p>
 *
 * @author zhj
 * @since 2021-12-13
 */
@Api(description = "排班信息列表")
@RestController
@RequestMapping("/web/innerDoctorWork")
public class InnerDoctorWorkController {

    @Autowired
    public InnerDoctorService innerDoctorService;
    @Autowired
    public InnerDoctorWorkService innerDoctorWorkService;
    @Autowired
    public RedisUtil redisUtil;

    // 根据医生id获取医生的值班信息
    @ApiOperation(value = "根据医生id获取医生的值班信息 ")
    @GetMapping("getDoctorWorkInfoList/{rdSession}/{id}")
    public R getDoctorWorkInfoList(
            @PathVariable String rdSession,
            @PathVariable String id) {
        // 判断是否登录
        String userId = (String) redisUtil.get("session:" + rdSession);
        if (userId == null) {
            return R.error().message("请重新登录");
        }

        ArrayList<InnerDoctorWorkVO> innerDoctorWorkVOS = innerDoctorService.getDoctorWorkById(id);


        return R.ok().data("records", innerDoctorWorkVOS);
    }
}

